var fs=require("fs");
var path=require("path");
var stream=require("stream");
var Readable=stream.Readable;

var formPath=path.join(__dirname,'/form.txt');
var toPath=path.join(__dirname,'/to.txt');

var readable=fs.createReadStream(formPath);
var writable=fs.createWriteStream(toPath);

var rs=new Readable();

rs._read=function(){  //因为一执行rs.push()就会执行rs._read(),虽然没有用但必须要有这个函数
    
}

readable.on("data",function(chunk){
    chunk=chunk.toString("utf-8").toUpperCase();
    rs.push(chunk);
});

readable.on("end",function(){
    console.log("readable ended");
})

rs.pipe(writable);
